import { NestFactory } from "@nestjs/core";
import { HardwareModule } from "./hardware.module";
import { MicroserviceOptions, Transport } from "@nestjs/microservices";
import { configuration } from "../../../config/config";

async function bootstrap() {
  const app = await NestFactory.create(HardwareModule, { bufferLogs: true });
  app.enableCors();
  await Promise.all([
    app.listen(configuration.hardwareServer.http_port),
    app.connectMicroservice<MicroserviceOptions>({
      transport: Transport.NATS,
      options: {
        servers: ["nats://localhost:4222"],
      },
    }),
  ]);
  await app.startAllMicroservices();
  console.log(
    "Hardware Server is running on http port " +
      configuration.hardwareServer.http_port,
    "nats start",
  );
}

bootstrap();
